package com.ittony.blog.dto;

public class JsonResult<T> {

    private Integer code;

    private String msg;

    private T data;

    public JsonResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public JsonResult(){

    }

    public JsonResult fail(){
        return new JsonResult(1,"Operation Failed",null);
    }

    public JsonResult fail(String msg){
        return new JsonResult(1,msg,null);
    }

    public JsonResult ok(){
        return new JsonResult(0,"Operation Success",data);
    }

    public JsonResult ok(T data){
        return new JsonResult(0,"Operation Success",data);
    }

}
